import java.io.*;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class 最大食物链计数 {
    //https://www.luogu.com.cn/problem/P4017
    public static int MAXN = 5001;
    public static int MAXM = 500001;
    public static int MOD = 80112002;
    //链式前向星
    public static int[] head = new int[MAXN];
    public static int[] next = new int[MAXM];
    public static int[] to = new int[MAXM];
    public static int cnt = 1;
    
    public static int n;
    public static int m;
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static void main(String[] args) throws IOException{
        n = in.nextInt();
        m = in.nextInt();
        //入度表
        int[] indegreee = new int[n + 1];
        //图和表存储完成
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            addEdge(a,b);
            indegreee[b]++;
        }
        int ans = -1;
        //存储当前的点信息,从入度为0的不断往下传递
        int[] lines = new int[n + 1];
        Queue<Integer> queue = new LinkedList<>();
        //遍历入度表
        for (int i = 1; i <= n; i++) {
            if(indegreee[i] == 0){
                queue.add(i);
                lines[i] = 1;
            }
        }
        while(!queue.isEmpty()){
            int t = queue.poll();
            if(head[t] == 0){
                //此时这个是最后一个点了
                ans = (ans + lines[t]) % MOD;
            }else{
                for (int ei = head[t]; ei != 0; ei = next[ei]) {
                    lines[to[ei]] = (lines[t] + lines[to[ei]]) % MOD;
                    if(--indegreee[to[ei]] == 0){
                        queue.add(to[ei]);
                    }
                }
            }
        }
        out.println(ans);
        out.close();
    }

    private static void addEdge(int a, int b) {
        next[cnt] = head[a];
        head[a] = cnt;
        to[cnt++] = b;
    }

    public static class Read{
        StringTokenizer st = new StringTokenizer("");
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String next() throws IOException{
            while(!st.hasMoreTokens()){
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }
        int nextInt() throws IOException{
            return Integer.parseInt(next());
        }
    }
}
